#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
int weight[18]={7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
char m[12]={'1','0','X','9','8','7','6','5','4','3','2'};
int main(){
	bool pass=true;
	int sum=0;
	int n;
	cin>>n;
	string a;
	for(int i=0;i<n;i++){
		cin>>a;
	}
	for(int i=0;i<17 && pass;i++){
		if(a[i]>='0' && a[i]<='9'){
			sum+=(a[i]-'0')*weight[i];
		}else{
			pass=false;
		}
	}
	sum=sum%11;
	if(a[17]!=m[sum] || !pass){
		pass=false;	
		cout<<a<<endl;
	}
	if(pass){
	
		cout<<"ALL PASS"<<endl;
	}
		system("pause");
	return 0;
} 
